//
//  An_uiviewViewController.m
//  Animation_UIview1
//
//  Created by 刘文超 on 2019/12/24.
//  Copyright © 2019 刘文超. All rights reserved.
//

#import "An_uiviewViewController.h"

@interface An_uiviewViewController ()
@property(nonatomic,strong)UIView *ls_bgView1;
@property(nonatomic,strong)UIView *ls_bgView2;
@property(nonatomic,strong)UIView *ls_bgView3;
@end

@implementation An_uiviewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    CGFloat view_width = ([UIScreen mainScreen].bounds.size.width-100);
    UIView *bgView1=[[UIView alloc]initWithFrame:CGRectMake(50, 100, view_width, 100)];
    [self.view addSubview:bgView1];
    bgView1.backgroundColor= [UIColor redColor];
    self.ls_bgView1 = bgView1;
    
    
    UIView *bgView2=[[UIView alloc]initWithFrame:CGRectMake(50, 200, view_width/2,100)];
    [self.view addSubview:bgView2];
    bgView2.backgroundColor = [UIColor blueColor];;
    self.ls_bgView2 = bgView2;
    
    
    UIView *bgView3=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(bgView2.frame), 200, view_width/2,100)];
    [self.view addSubview:bgView3];
    bgView3.backgroundColor = [UIColor greenColor];;
    self.ls_bgView3 = bgView3;
    
    
//    //说明需要执行的动画
//    [UIView beginAnimations:nil context:nil];
//    //设置动画时间
//    [UIView setAnimationDuration:2];
//    //设置动画速录
//    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
//    //设置动画延迟时间
//    [UIView setAnimationDelay:1];
//    //是否禁用动画 无动画效果
////    [UIView setAnimationsEnabled:YES];
//    //设置动画反向执行
//    [UIView setAnimationRepeatAutoreverses:YES];
//    //重复次数
//    [UIView setAnimationRepeatCount:2];
//
//    bgView.transform = CGAffineTransformMakeScale(1.2, 2.0);
//
//    //动画开始 结束执行方法
//    [UIView setAnimationWillStartSelector:@selector(animationStart)];
//    [UIView setAnimationDidStopSelector:@selector(animationStop)];
//
//
//    [UIView commitAnimations];
    
   
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//    [self ls_shuxingAnimation];
    [self ls_scalAnimation];
//    [self ls_zhuanchangAnimation];
    
}
-(void)animationStart
{
    NSLog(@"动画开始");
}
-(void)animationStop
{
   NSLog(@"动画结束");

}
#pragma mark -- 属性动画
-(void)ls_shuxingAnimation
{
    [UIView beginAnimations:@"framAnima" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationWillStartSelector:@selector(animationStart)];
    [UIView setAnimationDidStopSelector:@selector(animationStop)];
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    self.ls_bgView2.frame = self.ls_bgView1.frame;
    [UIView commitAnimations];
    
}
-(void)ls_scalAnimation
{
    [UIView beginAnimations:@"scalAnima" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationWillStartSelector:@selector(animationStart)];
    [UIView setAnimationDidStopSelector:@selector(animationStop)];
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    self.ls_bgView2.bounds = CGRectMake(0, 0, 50, 50);
    [UIView commitAnimations];
    
}
#pragma mark -- 转场动画
-(void)ls_zhuanchangAnimation
{
    
    [UIView beginAnimations:@"flipAnima" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationWillStartSelector:@selector(animationStart)];
    [UIView setAnimationDidStopSelector:@selector(animationStop)];
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.ls_bgView1 cache:YES];
    self.ls_bgView1.backgroundColor = [UIColor blackColor];
    [UIView commitAnimations];
}
@end
